package com.cal.utms.model.maintenance;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.cal.utms.dto.maintenance.ConfirmConfigDto;
import com.cal.utms.entity.ScreenConfirmation;

public class ConfirmConfigModel {
	
	public List<ScreenConfirmation> mapDtoToSC(ConfirmConfigDto confirmConfigDto){
		List<ScreenConfirmation> scList = new ArrayList<ScreenConfirmation>();
		Date date = new Date();
		ScreenConfirmation sc = null;
		String[] valueArr = confirmConfigDto.getValues().split(";");
		String[] localFieldArray = confirmConfigDto.getLocalFields().split(";");
		if(valueArr.length!= localFieldArray.length){
			confirmConfigDto.setSuccess(false);			
		}else{
			for(int i =0; i<valueArr.length; i++){
				sc = new ScreenConfirmation();
				sc.setScreen(confirmConfigDto.getScreen());
				sc.setField(valueArr[i]);
				//System.out.println(valueArr[i]+":"+localFieldArray[i]);
				sc.setLocalField(localFieldArray[i]);
				sc.setUser(confirmConfigDto.getUser());
				sc.setDate(date);
				scList.add(sc);
			}
		}
		
		return scList;		
	}

}
